<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>添加应用</title> {{>/WEB-INF/pages/common/meta_base.part.html}}
{{>/WEB-INF/pages/common/refs_base.part.html}}
</head>
<body>
	<!-- <div class="container"> -->
	{{>/WEB-INF/pages/common/layout_header.part.html}}

	<!--Con//Start-->
	<div class="container">
		<ul class="breadcrumb">
			<li><a href="{{ctx}}">首页</a></li>
			<li><a href="{{ctx}}/mam/appMain/list-view">应用管理</a></li>
			<li class="active">添加应用</li>
		</ul>
		<hr class="hr1" />
		<div class="container bor-tab bg-st-white">
			<div class="mar-st-a30">
				<div class="bor-bot pad-st-b2">
					<div class="row">
						<div class="col-6 text-left tit4-st">应用基本信息</div>
						<div class="col-6 text-right"></div>
					</div>
					<div class="hr"></div>
				</div>
				<form id="dataForm" name="dataForm" method="post"
					class="form-horizontal" action="{{ctx}}/mam/appMain/add"
					enctype="multipart/form-data">
					<div class="mar-st-a30">
						<table width="90%" border="0" align="center" cellpadding="0"
							cellspacing="0" class="tab-td-pa">
							<tr id="tr">
								<td width="100" align="right" for="focusedInput">应用标识：</td>
								<td width="39%" class="bd_sr" id="result"><input
									class="form-control wid75" name="identifier" type="text"
									onblur="identifierCheck()" id="identifier" btvd-type="required" />
									<input type="hidden" name="showResult" readonly="readonly"
									id="showResult" /></td>
								<td width="100" align="right" for="focusedInput">应用名称：</td>
								<td class="bd_sr"><input class="form-control wid75"
									id="app_name" name="app_name" onblur="checkName()" type="text"
									btvd-type="required" /> <input type="hidden" name="showResult"
									readonly="readonly" id="name_showResult" /></td>
							</tr>
							<tr>
								<td width="100" align="right">应用类别：</td>
								<td width="39%" class="bd_sr"><select name="categoryid"
									btvd-type="required" id="categoryid" class="form-control wid75">
										{{#lists}}
										<option value="{{id}}">{{name}}</option> {{/lists}}
								</select></td>
							</tr>
							<tr>
								<td align="right" class="control-group">应用简介：</td>
								<td colspan="3" class="bd_sr"><textarea id="discription"
										style="width: 754px; height: 62px;" class="form-control"
										name="discription" cols="" rows=""></textarea></td>
							</tr>
						</table>
					</div>

					<div class="hr-10"></div>
					<div class="text-center">
						<button type="submit" class="btn btn-primary btn-small tls"
							id="buttonsub">保存</button>
						<button type="button" class="btn btn-small tls btn-common"
							onclick="javascript:history.back();">返回</button>
					</div>
				</form>
			</div>
			<div class="hr-20"></div>
		</div>
	</div>
	{{>/WEB-INF/pages/common/layout_footer.part.html}}
</body>
</html>
<script type="text/javascript">

	$('#dataForm').validation();
	function identifierCheck() {
		   var identify = $("#identifier").val();
		   if(identify==""){
			 $("#identifier").attr("btvd-type","required");
			 $("#identifier").removeAttr("btvd-err");
				return;
		}
		var tel = /^[a-zA-Z]{1}([a-zA-Z0-9]+[.])+[a-zA-Z]{1}([A-z0-9]+)$/;
		var flag = tel.test(identify);
		if (!flag) {
			 $("#identifier").attr("btvd-err","该应用标识格式不正确，必须以字母开头，只允许包含英文字母、数字和（.）字符。例如：com.foreveross.cube");
			return ;
		}else{
			$("#identifier").removeAttr("btvd-err");
		}
		
		$.ajax({
			type : "GET",
			dataType : "json",
			url : "{{ctx}}/mam/appMain/checkIdentify",
			data : "identify=" + identify,
			success : function(data, textStatus) {
				if (data.result == "true") {
					 $("#identifier").attr("btvd-err","该应用标识ID已经被占用，请换别的试试！");
				} else {
					$("#identifier").removeAttr("btvd-err");
				}

			},
		});
	}

	function checkName() {
		var name = $("#app_name").val();
		if(name==""){
			 $("#app_name").attr("btvd-type","required");
			 $("#app_name").removeAttr("btvd-err");
				return;
		}
		var tel =/^[^`~!@#$%^&*()+=|\\\][\]\{\}:;'\,.<>/?]{1}[^`~!@$%^&()+=|\\\][\]\{\}:;'\,.<>?]{0,19}$/; 
		 var flag = tel.test(name);
		 if(!flag){
			 $("#app_name").attr("btvd-type","noSpecialChar");
				return;
		 }
		$.ajax({
			type : "POST",
			dataType : "json",
			url : "{{ctx}}/mam/appMain/checkName",
			data : "checkName=" + name,
			success : function(data, textStatus) {
				if (data.result == "true") {
					 $("#app_name").attr("btvd-err","该应用名称已经被占用，请换别的试试！");
				} else {
					$("#app_name").removeAttr("btvd-err");
				}

			},
		});

	}
</script>
